Skip to content

fix: prevent user/group ID collision in currency preference store#662

Merged
krokosik merged 4 commits into
oss-apps:mainfrom
jaredslorenz:fix/currency-state-collision
Jun 21, 2026
Merged

fix: prevent user/group ID collision in currency preference store#662
krokosik merged 4 commits into
oss-apps:mainfrom
jaredslorenz:fix/currency-state-collision

Conversation

@jaredslorenz

Copy link
Copy Markdown
Contributor

Description

Closes #661
Integer ID collision between user IDs and group IDs in currencyPreferenceStore caused friend balances to display in the wrong currency after tab navigation. The getPreference function's fallback chain checked groupDefaultCurrencies for any numeric key — so if a user's ID matched a group ID with USD as its default, navigating to the Groups tab would poison the store and convert that user's EUR balance to USD on re-render.
Changes:

currencyPreferenceStore.ts — getPreference now takes entityType?: 'group'; group currencies only consulted when entityType === 'group'
ConvertibleBalance.tsx — Added entityType?: 'group' prop; gates group currency lookup accordingly
CumulatedBalances.tsx — Forwards entityType prop through to ConvertibleBalance
GroupMyBalance.tsx — Passes entityType="group" as the only correct caller for group currency defaulting

AI assistance was used to help diagnose the root cause and implement the fix. All changes were thoroughly reviewed by me before submission.

Demo

Unable to reproduce locally without the specific user data, but the fix is verified by code analysis and unit tests covering the exact collision scenario.

Checklist

I have read CONTRIBUTING.md in its entirety
I have performed a self-review of my own code
I have added unit tests to cover my changes
The last commit successfully passed pre-commit checks
Any AI code was thoroughly reviewed by me

@krokosik krokosik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, but what happened to the .gitignore file?

- Wrap long getPreference call in ConvertibleBalance.tsx to satisfy
  prettier's print-width rule (CI was failing on this).
- Revert .gitignore to origin/main version. The previous commit had
  accidentally changed line endings (CRLF), causing git to treat it
  as a binary file with no content change.
@krokosik

Copy link
Copy Markdown
Collaborator

Re: the .gitignore change — it was an accidental line-ending change (CRLF) from a Windows machine, which made git treat it as a binary file with no actual content change. I've reverted it to match main exactly.

Also fixed a prettier formatting issue in ConvertibleBalance.tsx that was causing the CI check to fail. Both fixes are in commit 8040560.

The fix and tests are unchanged — great work on identifying the ID collision root cause! 🎯

@krokosik krokosik merged commit 80e75a3 into oss-apps:main Jun 21, 2026
1 check passed
@jaredslorenz

Copy link
Copy Markdown
Contributor Author

Thanks for catching that and cleaning it up! I appreciate the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Balance displays in USD instead of EUR for specific user after tab navigation

2 participants